#ifndef RTPPARSE_UDP_SOCKET_H
#define RTPPARSE_UDP_SOCKET_H

#include "UdpSocketHandle.h"
#include "PortManager.h"

class UdpSocket: public UdpSocketHandle {
public:
    class Listener {
    public:
        virtual ~Listener() = default;
    public:
        virtual void OnUdpSocketPacketReceived(UdpSocket *socket, const uint8_t* data, size_t len,
                                           const struct sockaddr* addr) = 0;
    };

public:
    UdpSocket(Listener *listener, std::string& ip,  uint16_t port, SocketFlags &flags);
    // UdpSocket(Listener *listener, std::string& ip, uint16_t minPort, uint16_t maxPort, SocketFlags &flags, uint64_t& portRangeHash);
    ~UdpSocket() override;

public:
    void UserOnUdpDatagramReceived(const uint8_t* data, size_t len,
                                           const struct sockaddr* addr) override;

private:
    Listener *listener { nullptr };
    bool fixedPort { false };
    uint64_t portRangeHash { 0u };
};

#endif // RTPPARSE_UDP_SOCKET_H